<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="structures.User"%>
<%@ page import="structures.AD"%>
<%
	User user = (User) session.getAttribute("user");
%>
<%
	AD advertisement = (AD) session.getAttribute("advertisement");
	session.removeAttribute("advertisement");
%>
<%
	String imageSource = "http://localhost:8080/DatabaseRESTWebService/GetADImage?idAdvertisement="
			+ advertisement.getIdAdvertisement();
%>
<%
	String imageSourceNoPort = "http://localhost/DatabaseRESTWebService/GetADImage?idAdvertisement="
			+ advertisement.getIdAdvertisement();
%>

<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TiVendoIo - Confirm Insertion</title>

<!-- Bootstrap -->
<link href="/serviceTechnologies/bootstrap/css/bootstrap.min.css"
	rel="stylesheet">
<link href="/serviceTechnologies/bootstrap/css/select2-bootstrap.css"
	rel="stylesheet">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

<link
	href="//netdna.bootstrapcdn.com/font-awesome/4.0.0/css/font-awesome.css"
	rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<script
	src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#footer').load('/serviceTechnologies/common/footer.jsp');
		$('#navbar').load('/serviceTechnologies/common/navbar.jsp');
	});
	</script>

<script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '222737361268089',
          status     : false,
          xfbml      : true
        });
        
     	
        
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//connect.facebook.net/it_IT/all.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));
      
      $(document).ready(function() {
    	  $("#FacebookPublish").click(function(){
    		  FB.ui(
    				  {
    				    method: 'feed',
    				    name: 'TiVendoio',
    				    picture: '<%=imageSource%>',
    				    caption: 'I\'m selling: <%=advertisement.getTitle()%>',
    				    description: 'Product description: <%=advertisement.getDescription()%>',
    				    link: 'http://localhost:8080/facebook/'
    				  },
    				  function(response) {
    				    if (response && response.post_id) {
    				      alert('Post was published.');
    				    } else {
    				      alert('Post was not published.');
    				    }
    				  }
    				);  
    	  }); 
    	});
      
      
      
		
      (function() {
    	   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    	   po.src = 'https://apis.google.com/js/client:plusone.js';
    	   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
    	 })();
      
    </script>

</head>
<body>

	<!--  Facebook connection -->
	<div id="fb-root"></div>

	<div id="navbar"></div>

	<div class="container">

		<div class="page-header">
			<h1>Advertisement successfully created!</h1>
		</div>

		<div class="row">
			<div class="col-md-3"></div>
			<div class="col-md-6">
				<div class="jumbotron" style="text-align: center;">
					<img src="<%=imageSource%>"
						style="display: block; margin-left: auto; margin-right: auto; width: 194px; height: 162px;">
					<form class="form-horizontal" role="form">
						<div class="form-group">
							<label for="title" class="col-sm-2 control-label">Title</label>
							<div class="col-sm-10">
								<p class="form-control-static" id="title"><%=advertisement.getTitle()%></p>
							</div>
						</div>
						<div class="form-group">
							<label for="desc" class="col-sm-2 control-label">Description</label>
							<div class="col-sm-10">
								<p class="form-control-static" id="desc"><%=advertisement.getDescription()%></p>
							</div>
						</div>
						<div class="form-group">
							<label for="price" class="col-sm-2 control-label">Price</label>
							<div class="col-sm-10">
								<p class="form-control-static" id="price"><%=advertisement.getPrice()%></p>
							</div>
						</div>
					</form>

				</div>
			</div>
		</div>


		<div class = "row">
			<div class="omb_login">
				<h3 class="omb_authTitle">Share your Ad</h3>
				<div class="row omb_row-sm-offset-3 omb_socialButtons">
					<div class="col-xs-4 col-sm-2">
						<a id="FacebookPublish"
							class="btn btn-lg btn-block omb_btn-facebook"> <i
							class="fa fa-facebook visible-xs"></i> <span class="hidden-xs">Facebook</span>
						</a>
					</div>

					<script>
			$(document).ready(function() {
			   // Create the twitter URL
			    var tweeturl = "url=http://iselltoyou.com&via=ISellToYou&text=I\'m selling: <%=advertisement.getTitle()%> Product description: <%=advertisement.getDescription()%>
					";
										var url = 'http://twitter.com/share?'
												+ encodeURI(tweeturl);
										document.getElementById("tweetAD")
												.setAttribute("href", url);
									});
				</script>

					<div class="col-xs-4 col-sm-2">
						<a id="tweetAD" target="_blank"
							class="btn btn-lg btn-block omb_btn-twitter"> <i
							class="fa fa-twitter visible-xs"></i> <span class="hidden-xs">Twitter</span>
						</a>
					</div>

					<div class="col-xs-4 col-sm-2">

						<span id="GShare" class="g-interactivepost"
							data-contenturl="http://www.amazon.it/"
							data-clientid="200831826702-javfst7ignashgjschib6osh972ruhhc.apps.googleusercontent.com"
							data-cookiepolicy="single_host_origin"
							data-prefilltext="TiVendoio       I'm selling: <%=advertisement.getTitle()%> Product description: <%=advertisement.getDescription()%>"
							data-calltoactionlabel="OPEN"
							data-calltoactionurl="https://dev.diesocialisten.at/google+">

							<a id="GShare" class="btn btn-lg btn-block omb_btn-google"> <i
								class="fa fa-google-plus visible-xs"></i> <span
								class="hidden-xs">Google+</span>
						</a>
						</span>

					</div>
				</div>

			</div>
		</div>
		<br>
	</div>
	<!-- End Container -->

	<div id="footer"></div>
	<!-- End footer -->


</body>
</html>